/* 获取命令行传过来的参数 */
#include<iostream>
using namespace std;

string ename[2],iname[2],fname[2],oname;

// 解析命令行参数，共7个参数，并打印出来内容
/*
$ g++ a1_get_cmd_params.cpp
$ ./a.out exon_R1 exon_R2 intronR1 intronR2 fq1 fq2 outerPrefix
*/
int main(int narg, char** args){
  // 参数个数 narg
  // 字符串 args
  for(int w=0; w<narg; w++){
    cout << w << ": " << args[w] << endl;
  }
  printf("========");

  int i;
  string *sargs;
  
  int argscnt = 0;
  bool wrong_args = false;
  sargs = new string[narg]; 

  for(i=0;i<narg-1;i++){
    sargs[i] = string(args[i+1]);
  }

  for(i=0;i<narg-1;i++){
    if(argscnt == 0){
      ename[0] = sargs[i];
    }else if(argscnt == 1){
      ename[1] = sargs[i];
    }else if(argscnt == 2){
      iname[0] = sargs[i];
    }else if(argscnt == 3){
      iname[1] = sargs[i];
    }else if(argscnt == 4){
      fname[0] = sargs[i];
    }else if(argscnt == 5){
      fname[1] = sargs[i];
    }else if(argscnt == 6){
      oname = sargs[i];
    }
    argscnt++;    
  }

  if (argscnt != 7){
    cout << "Usage:" << endl;
    cout << args[0] << " sam_file_exon_R1 sam_file_exon_R2 sam_file_intron_R1 sam_file_intron_R2 fastq_file_R1 fastq_file_R2 output" << endl;  
    exit(0);
  }

  cout << "exon:" << ename[0] << ", " << ename[1] << endl;
  cout << "intron:" << iname[0] << ", " << iname[1] << endl;
  cout << "fname:" << fname[0] << ", " << fname[1] << endl;
  cout << "oname:" << oname << endl;

  return 0;
}
